﻿using System;
using System.Collections.Generic;
using System.Text;
using PostSharp.Aspects.Dependencies;

namespace Arcana.Contract.Property.All.Are.Not
{
    [Serializable]
    [ProvideAspectRole(Roles.Contract)]
    [ProvideAspectRole(Roles.Property)]
    [ProvideAspectRole(Roles.Conditional)]
    [AspectRoleDependency(AspectDependencyAction.Commute, Roles.Conditional)]
    public sealed class InstanceOfAttribute : EnumerableComparingContractBase.UniversalQuantification
    {
        private Type _type;

        public InstanceOfAttribute(Type type)
        {
            if (type == null) throw new ArgumentNullException();
            _type = type;
        }

        protected override bool ValidateItem(object item)
        {
            return item == null || !item.GetType().Equals(_type);
        }
    }
}
